#include <stdio.h>
#include <stdlib.h>

struct FenwickTree {
	int *a;
	int *b;
	int n;
};

int
rsq(int k)
{
	int sum = 0;
	while (k >= 0) {
		sum += b[k];
		k = k & (k + 1) - 1;
	}
	return sum;
}

/*
 * rsq(x1,y1,x2,y2)
 *
 *      y1    y2
 *  +---+-----+----+
 *  |   |     |    |
 *x1+---+-----+----+
 *  |   |*****|    |
 *x2+---+-----+----+
 *  |   |     |    |
 *  |   |     |    |
 *  +---+-----+----+
 *
 * update(x,y,d)
 */
